const {seq, DataTypes} = require('../sequelize')
const { Role } = require('./Role') 
const { Auth } = require('./Auth')

const RoleAuthAttributes = {
    role_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        // unique: 'index_role_auth_roleid_authid',
        Comment: '角色id',
        references: {
            model: Role,
            id: 'id'
        }
    },
    auth_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        // unique: 'index_role_auth_roleid_authid',
        Comment: '权限id',
        references: {
            model: Auth,
            id: 'id'
        }
    }
}

const RoleAuth = seq.define('yyb_role_auth',RoleAuthAttributes, {
    createdAt: true,
    updatedAt: true,
    timestamps: false,
    freezeTableName: true
})

RoleAuth.sync() 

module.exports = {
    RoleAuth,
    RoleAuthAttributes 
} 
